//2009/08/19 16:12:08//
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <sstream>
#include <algorithm>

using namespace std;

class PaperRockScisQuals
{
public:
    int whoPassed(vector <string> players)
    {
		int mmax = -1;
		int dex = -1;
		for(int i=0; i<players.size(); i++)
		{
			int temp = 0;
			for(int j=0; j<players.size(); j++)
			{
				if(i!=j)
				{
					int wins = 0;
					int ties = 0;
					for(int k=0; k<players[i].size(); k++)
					{
						if(iswins(players[i][k], players[j][k])) wins ++;
						else if(isties(players[i][k], players[j][k])) ties ++;
					}
					int loses = players[i].size() - wins - ties;
					if(wins > loses) temp += 2;
					else if(wins == loses) temp ++;
				}
			}
			if(temp > mmax || mmax == -1)
			{
				mmax = temp;
				dex = i;
			}
		}
		return dex;
    }
	bool iswins(char a, char b)
	{
		if(a == 'P' && b == 'R') return true;
		if(a == 'R' && b == 'S') return true;
		if(a == 'S' && b == 'P') return true;
		return false;
	}
	bool isties(char a, char b)
	{
		return a ==b;
	}
};
